package com.jintian.smart.kernel.autoconfigure.nacos;

import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
import com.alibaba.nacos.spring.context.annotation.config.EnableNacosConfig;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import javax.annotation.PostConstruct;

/**
 * 解决com.alibaba.boot.nacos.config.binder.NacosBootConfigurationPropertiesBinder的Spring兼容性问题
 * 废弃原因：私库 nacos-spring-context-2.1.0 已修复此问题
 */
@Deprecated
@ConditionalOnProperty(name = "smart.nacos.patch", matchIfMissing = false)
@EnableConfigurationProperties(value = NacosConfigProperties.class)
@ConditionalOnClass(name = "org.springframework.boot.context.properties.bind.Binder")
@AutoConfigureAfter(name = "com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration")
@Import(value = {NacosConfigBootBeanDefinitionRegistrar.class})
@EnableNacosConfig
@Configuration(proxyBeanMethods = false)
public class NacosConfigStarter {
    public NacosConfigStarter() {
    }

    @PostConstruct
    public void init() {
        System.out.println("初始化Nacos配置");
    }
}